# -*- coding: utf-8 -*-

import time, os
import sys
import unittest
from HTMLTestRunner import HTMLTestRunner
from test import test_unit
from test import test_unit_test2


sys.path.append('./test')
test_dir = './test'       #指定当前文件夹下的Interface目录
# file = unittest.defaultTestLoader.discover(test_dir, pattern='test_unit_*.py')    #匹配开头为test的py文件
test = 'AddTrackNo'
file = unittest.defaultTestLoader.loadTestsFromTestCase(test_unit.test)
file1 = unittest.defaultTestLoader.loadTestsFromTestCase(test_unit_test2.test_unit_test2)

if __name__=="__main__":

    now = time.strftime("%Y-%m-%d %H-%M-%S", time.localtime(time.time()))    # 取当前时间
    public_path = os.path.dirname(os.path.abspath(sys.argv[0]))       # 获取当前运行的.py文件所在的绝对路径
    filename = public_path + "\\Report\\" + now + "report.html"   #保存的报告路径和名称
    fp = open(filename, 'wb')
    runner = HTMLTestRunner(stream=fp,
                            title="test",
                            description="test2"
                            )
    runner.run(file)     #执行测试套件
    runner.run(file1)
    print file
    fp.close()